﻿@model article_category

@{
    ViewData["Title"] = "文章分类详情";
    var cate = Model;
}

<div class="row">
    <form id="ajaxForm" enctype="multipart/form-data" class="form-horizontal">
        <input type="hidden" name="id" id="id" value="@cate.id"/>

        <div class="container-fluid">
            <div class="row form-group">
                <label class="control-label col-md-2">分类名称</label>
                <div class="col-md-10">
                    <input class="form-control" name="category_name" id="category_name" type="text" value="@cate.category_name" />
                </div>
            </div>
            <div class="row form-group">
                <label class="control-label col-md-2">图标(400x400)</label>
                <div class="col-md-6">
                    <input class="form-control" name="img" id="img" type="file" placeholder="绝对路径,或者相对路径" accept="image/*" />
                </div>
                <div class="col-md-4">
                    <a href="@cate.img" target="_blank" title="查看图片"><img src="@cate.img" height="100" /></a>
                </div>
            </div>
            <div class="row form-group">
                <label class="control-label col-md-2">排序数字</label>
                <div class="col-md-10">
                    <input class="form-control" name="sort" id="sort" type="number" max="100" min="1" value="@cate.sort" />
                </div>
            </div>
            <div class="row form-group">
                <label class="control-label col-md-2">是否显示</label>
                <div class="col-md-10">
                    <input class="i-checks" name="is_show" id="is_show" type="checkbox" value="true" @(cate.is_show ? "checked" : "") />
                </div>
            </div>
            <div class="row form-group">
                <label class="control-label col-md-2">访问url</label>
                <div class="col-md-10">
                    <input class="form-control" type="text" value="/article/list/@cate.id" readonly/>
                    <div class="text text-primary">
                        可以把此链接复制到热门链接<span style="color:red;">(置顶)</span>中, <a href="/article/list/@cate.id" target="_blank">点此查看效果</a>
                    </div>
                </div>
            </div>
            <div class="row form-group">
                <label class="control-label col-md-2">创建时间</label>
                <div class="col-md-10">
                    <input class="form-control" name="create_time" id="create_time" type="text" value="@cate.create_time.ToLocalDateTimeString()" disabled />
                </div>
            </div>            <div class="row form-group">
                <label class="control-label col-md-2">更新时间</label>
                <div class="col-md-10">
                    <input class="form-control" name="last_update" id="last_update" type="text" value="@cate.last_update.ToLocalDateTimeString()" disabled />
                </div>
            </div>
            <div class="row form-group">
                <div class="col-md-6 col-md-offset-2">
                    <button type="button" class="btn btn-primary" onclick="SaveArticleCategory()">保存</button>
                </div>
            </div>
        </div>
    </form>
</div>

@section scripts{
    <script type="text/javascript">

        function SaveArticleCategory() {
            if ($("#category_name").val().length === 0) {
                utils.ShowError("请输入分类名称");
                return;
            }

            $("#ajaxForm").ajaxSubmit({
                type: 'post',
                url: '@Url.Action("Update")',
                data: {

                },  // data是作为额外提交的表单数据
                success: function (e) {
                    if (e.msg == 'ok') {
                        utils.ShowSuccess(e.data, function () {
                            location.reload(true);
                        });
                    }
                },
                error: function (e) {
                    utils.ShowError(e.data);
                }
            });
        }
    </script>
}